import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: nn
 * Date: 2025-05-20
 * Time: 上午9:56
 */
public class FirstText {
    //测试百度搜索关键词:迪丽热巴

    void text01() throws InterruptedException {
        //1.打开浏览器 使用驱动来打开
        WebDriverManager.chromedriver().setup();
        //添加浏览器配置： 创建驱动对象要强制指定允许访问所有的链接
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");

        WebDriver driver = new ChromeDriver(options);
        Thread.sleep(3000);

        //2.输⼊百度⽹址:https://www.baidu.com
        driver.get("https://www.baidu.com");
        Thread.sleep(3000);

        //3、找到输⼊框并输⼊“迪丽热巴”
        driver.findElement(By.cssSelector("#kw")).sendKeys("迪丽热巴");
        Thread.sleep(3000);

        //4、找到“百度⼀下”按钮并点击
        driver.findElement(By.cssSelector("#su")).click();
        Thread.sleep(3000);

        //5、关闭浏览器
        driver.quit();
    }
    //2024-07-自动化概念代码结束
}
